/*
 * uart.h
 *
 *  Created on: 30-03-2011
 *      Author: zeus
 */

#include <portmacro.h>

#ifndef UART_H_
#define UART_H_

#define uartDLAB                ( ( unsigned char ) 0x80 )
#define uartCLOCK_SCALING       ( ( unsigned long ) 16 )
#define uartINVALID_QUEUE       ( ( xQueueHandle ) 0 )
#define uartNO_BLOCK            ( ( portTickType ) 0 )
#define uartFIFO_ON             ( ( unsigned char ) 0x01 )
#define uartFIFO_CLEAR          ( ( unsigned char ) 0x06 )
#define uartCLOCK_HZ            configCPU_CLOCK_HZ / 4
#define uartTHRE_EN             ( ( unsigned char ) 0x01 )
#define uartSOURCE_THRE         ( ( unsigned char ) 0x02 )
#define uartSOURCE_RX           ( ( unsigned char ) 0x04 )
#define uartSOURCE_ERROR        ( ( unsigned char ) 0x06 )
#define uartSOURCE_RX_TIMEOUT   ( ( unsigned char ) 0x0c )
#define uartINTERRUPT_SOURCE_MASK       ( ( unsigned char ) 0x0f )

typedef enum
{
  uartNO_PARITY,
  uartODD_PARITY,
  uartEVEN_PARITY = 3
}eParity;

typedef enum
{
  uartSTOP_1,
  uartSTOP_2
}eStopBits;

typedef enum
{
  uartBITS_5,
  uartBITS_6,
  uartBITS_7,
  uartBITS_8
}eDataBits;

typedef enum
{
  uart300 = 300,
  uart600 = 600,
  uart1200 = 1200,
  uart2400 = 2400,
  uart4800 = 4800,
  uart9600 = 9600
} eBaud;

void vUARTInit( eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength );
signed portBASE_TYPE xUARTGetChar( signed char *pcRxedChar, portTickType xBlockTime );
signed portBASE_TYPE xUARTPutChar( signed char cOutChar, portTickType xBlockTime );
void vUARTPutString( const signed char * const pcString, unsigned short usStringLength );

#endif /* UART_H_ */
